package de.carcophan.jimdb.service.sessionbeans;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.jboss.logging.Logger;

@LocalBean
@Stateless
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public class IsolatedTransactions {

   private static Logger logger = Logger.getLogger(IsolatedTransactions.class);

   @PersistenceContext
   private EntityManager em;

   @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
   public void persist(Object transientObject) {
      try {
         em.persist(transientObject);
      } catch (Exception e) {
         logger.error(e);
      }
   }

}
